package com.zl.tcbnewcar.ui.dialog;

import android.app.Activity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.zl.tcbnewcar.R;
import com.zl.tcbnewcar.base.BaseDialog;
import com.zl.tcbnewcar.utils.SystemUtils;

/**
 * Created by Administrator on 2018/4/24.
 */

public class CallPhoneDialog extends BaseDialog implements View.OnClickListener {

    private TextView tvTePhone;
    private TextView tvPhone;
    private TextView tvCancel;
    private String tePhone;
    private String phone;

    public CallPhoneDialog(Activity mActivity, String tePhone, String phone) {
        super(mActivity);
        this.tePhone = tePhone;
        this.phone = phone;
        initView();
        initListener();
    }

    private void initListener() {
        tvTePhone.setOnClickListener(this);
        tvPhone.setOnClickListener(this);
        tvCancel.setOnClickListener(this);
    }

    private void initView() {
        View inflate = LayoutInflater.from(mActivity).inflate(R.layout.choose_phone_layout, null);
        tvTePhone = inflate.findViewById(R.id.tv_te_phone);
        tvPhone = inflate.findViewById(R.id.tv_phone);
        tvCancel = inflate.findViewById(R.id.tv_cancel);
        if (!TextUtils.isEmpty(tePhone)) {
            tvTePhone.setText("特约电话：" + tePhone);
        } else {
            tvTePhone.setText("特约电话：无");
        }
        if (!TextUtils.isEmpty(phone)) {
            tvPhone.setText("联系电话：" + phone);
        } else {
            tvPhone.setText("联系电话：无");
        }
        initPopupWindow(inflate);
    }

    @Override
    public void onClick(View view) {
        dismissDialog();
        switch (view.getId()) {
            case R.id.tv_te_phone:
                SystemUtils.call(mActivity, tePhone);
                break;
            case R.id.tv_phone:
                SystemUtils.call(mActivity, phone);
                break;
        }
    }
}
